package com.ruoyi.project.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.business.domain.Slquestion;
import com.ruoyi.project.business.service.ISlquestionService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 申论题库管理Controller
 *
 * @author hongwj
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/business/slquestion" )
@Slf4j
public class SlquestionController extends BaseController {
    @Autowired
    private ISlquestionService slquestionService;

    /**
     * 查询申论题库管理列表
     */
    @PreAuthorize("@ss.hasPermi('business:slquestion:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(Slquestion slquestion) {
        startPage();
        List<Slquestion> list = slquestionService.selectSlquestionList(slquestion);
        return getDataTable(list);
    }

    /**
     * 查询所有申论题库管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:slquestion:all')" )
    @Log(title = "申论题库管理" , businessType = BusinessType.OTHER)
    @GetMapping("/all/slquestions" )
    public AjaxResult all(Slquestion slquestion) {
        List<Slquestion> list = slquestionService.selectSlquestionList(slquestion);
        return success(list);
    }

    /**
     * 导出申论题库管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:slquestion:export')" )
    @Log(title = "申论题库管理" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, Slquestion slquestion) {
        List<Slquestion> list = slquestionService.selectSlquestionList(slquestion);
        ExcelUtil<Slquestion> util = new ExcelUtil<Slquestion>(Slquestion. class);
        util.exportExcel(response, list, "申论题库管理数据" );
    }

    /**
     * 获取申论题库管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:slquestion:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(slquestionService.selectSlquestionById(id));
    }

    /**
     * 新增申论题库管理
     */
    //@PreAuthorize("@ss.hasPermi('business:slquestion:add')" )
    @Log(title = "申论题库管理" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Slquestion slquestion) {
        return toAjax(slquestionService.insertSlquestion(slquestion));
    }

    /**
     * 修改申论题库管理
     */
    //PreAuthorize("@ss.hasPermi('business:slquestion:edit')" )
    @Log(title = "申论题库管理" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Slquestion slquestion) {
        return toAjax(slquestionService.updateSlquestion(slquestion));
    }

    /**
     * 删除申论题库管理
     */
    //@PreAuthorize("@ss.hasPermi('business:slquestion:remove')" )
    @Log(title = "申论题库管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(slquestionService.deleteSlquestionByIds(ids));
    }
}
